<?php
$modification = $this->feature;
$allComments = $modification['details']['comments'];
$hasComments = (sizeof($allComments) > 0) ? true : false;
?>
<a class="btn btn-info btn-small" href="<?= $this->url(array('id' => $this->projectId), 'feature'); ?>"><i class="icon-white icon-circle-arrow-left"></i> Features</a>
<div id="view-content">
    <h2>Feature: <?= $modification['details']['main']->title ?></h2>
    <div class="row-fluid">
        <div class="well">
            <fieldset>
                <legend>Description
                    <?php
                    $mainUserType = ($modification['details']['main']->addedByAdmin) ? "Admin" : "Client";
                    ?>
                    <span class="label label-warning"><i class="icon-white icon-bookmark"></i> <?= $mainUserType ?></span>
                </legend>
                <?= $modification['details']['main']->description ?>
            </fieldset>        
            <?php
            $mainHasImages = (sizeof($modification['details']['main']->images) > 0) ? true : false;
            if ($mainHasImages) {
                ?>
                <fieldset>
                    <legend>Images</legend>
                    <?php foreach ($modification['details']['main']->images as $image) { ?>
                        <a href="<?= $image->url ?>" target="_blank"><img src="<?= $image->url ?>" class=" img-polaroid" style="width: 140px; height: 140px;"/></a><br>
                    <?php }
                    ?>
                </fieldset>
            <?php } ?>            
        </div>
        <?php
        if ($hasComments) {
            $index = 1;
            foreach ($allComments as $comment) {
                $userType = ($comment->addedByAdmin) ? "Admin" : "Client";
                ?>
                <div class="span11 well">
                    <div class="span1">
                        <h1><?= $index ?></h1>
                        <span class="label label-warning"><i class="icon-white icon-bookmark"></i> <?= $userType ?></span>
                    </div>
                    <div class="span11">                     
                        <?= $comment->description ?><br>
                        <?php
                        $images = $comment->images;
                        $hasImages = (sizeof($images) > 0) ? true : false;
                        if ($hasImages) {
                            ?>
                            <hr>                              
                            <?php foreach ($images as $image) { ?>
                                <a href="<?= $image->url ?>" target="_blank"><img src="<?= $image->url ?>" class=" img-polaroid" style="width: <?= $image->width ?>px; height: <?= $image->height ?>px;"/></a><br>
                            <?php }
                            ?>                             
                        <?php }
                        ?>                     
                    </div>

                </div>
                <?php
                $index++;
            }
        }
        ?>

    </div>
    <div class="row-fluid">
        <div class="well">
            <fieldset>
                <legend>Make New Comment</legend>
                <?= $this->form ?>
            </fieldset>            
        </div>  
    </div>

</div>